package com.shadow.common.exception;

import com.shadow.common.enums.RStatusEnums;
import lombok.Getter;
import lombok.Setter;

/**
 * 通用自定义异常类型.
 * @author Pbody
 * @date: 2019-03-18 14:29
 */
@Getter
@Setter
public class RException extends RuntimeException {

    private static final long serialVersionUID = 8346870061516697903L;

    /**
     * 处理结果，失败.
     **/
    private Integer code = 0;
    /**
     * 错误状态码.
     **/
    private Integer status = RStatusEnums.ERROR.getValue();
    /**
     * 错误描述消息.
     **/
    private String msg;

    /**
    * 异常构造.
    * @param msg 异常消息
    **/
    public RException(final String msg) {
        super(msg);
        this.msg = msg;
    }

    /**
     * 异常构造.
     * @param msg 异常消息
     * @param ex 异常对象
     **/
    public RException(final String msg, final Throwable ex) {
        super(msg, ex);
        this.msg = msg;
    }
    /**
     * 异常构造.
     * @param status 状态码
     * @param msg 异常消息
     **/
    public RException(final Integer status, final String msg) {
        super(msg);
        this.status = status;
        this.msg = msg;
    }

    /**
    * 异常构造.
    * @author pbody
    * @date 16:04 2022/10/20
    * @param code 处理标识
    * @param status 状态码
    * @param msg 异常消息
    * @param ex 异常对象
    * @return
    **/
    public RException(final Integer code, final Integer status, final String msg, final Throwable ex) {
        super(msg, ex);
        this.msg = msg;
        this.code = code;
        this.status = status;
    }
}
